#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>


void ShellSore(int *a,int n)
{
	int gap = n;
	while (gap > 1)
	{
		gap = gap / 3 + 1;
		for (int i = 0; i < n - gap; i++)
		{
			int end = i;
			int tem = a[end + gap];
			while (end >= 0)
			{
				if (tem < a[end])
				{
					a[end + gap] = a[end];
					end -= gap;
				}
				else
				{
					break;
				}
			}
			a[end + gap] = tem;
		}
	}
	
}

int main()
{
	int a[] = { 9 ,8,6,5,4,3,2,2,1,0 };
	int len = sizeof(a) / sizeof(int);
	ShellSore(a, len);
	for (int i = 0; i < len; i++)
	{
		printf("%d ", a[i]);
	}

	return 0;
}